/**
 * SDK管理类;
 */

import { glConfig } from "../Config/GLConfig";

class GLSDKMgr {
	ALIPAY_ENTRY: string = "com/entertainment/enjoyeveryday/alipay/AlipayEntry";
	NATIVE_HELPER: string = "org/cocos2dx/utils/NativeHelper";
	// WX_ENTRY: string = "org/cocos2dx/changcheng/wxapi/WXEntryActivity";
	WX_SENDER: string = "org/cocos2dx/javascript/AppActivity";//"org/cocos2dx/changcheng/wxapi/SendToWXActivity";
	VIOCE_RECORD: string = "org/cocos2dx/utils/VoiceRecord";
	Get_CLIPBOARD: string = "org/cocos2dx/javascript/AppActivity";
	Set_CLIPBOARD: string = "org/cocos2dx/javascript/AppActivity";

	NONE_STRING_PARAM: string = "()Ljava/lang/String;"; //一个字符串
	ONE_STRING_PARAMS: string = "(Ljava/lang/String;)V"; //一个字符串无返回值;
	TWO_STRING_PARAMS: string = "(Ljava/lang/String;Ljava/lang/String;)V"; //两字符串无返回值;

	BACKING: boolean = false;

	init() {
		if (cc.sys.isNative) {
			this.registerAppVest();
		}
		if (glConfig.loginType.qqlogin) {
			this.registerQQ(glConfig.qqappid);
		}
		if (glConfig.loginType.wxlogin && cc.sys.isNative) {
			cc.vv.wxChatMgr.regToWx()
		}
	}
	initOSS() {
		var endpoint = cc.vv.GLConfig.OSS_ENDPOINT;
		var bucketname = cc.vv.GLConfig.OSS_BUCKET_NAME;
		var accesskey = cc.vv.GLConfig.OSS_ACCESSKEYID;
		var accesskeysecret = cc.vv.GLConfig.OSS_ACCESSKEYSECRET;
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "initOSS",
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", endpoint, bucketname, accesskey, accesskeysecret);
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			jsb.reflection.callStaticMethod("AppController", "initOSS:bucketname:accesskey:accesskeysecret:", endpoint, bucketname, accesskey, accesskeysecret);
		}
	}
	registerAppVest() {//注册高防御
		var accesskey = cc.vv.GLConfig.AppVestaccesskey;
		var uuid = cc.vv.GLConfig.AppVestuuid;
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "registerAppVest", "(Ljava/lang/String;Ljava/lang/String;)V", accesskey, uuid);
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			jsb.reflection.callStaticMethod("AppController", "registerAppVest:uuid:", accesskey, uuid);
		}
	}
	registerQQ(qqappid) {
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "registerQQWithAppid", "(Ljava/lang/String;)V", qqappid);
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			jsb.reflection.callStaticMethod("AppController", "registerQQ:", qqappid);
		}
	}

	registerWeChat(wxappid) {
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "registerWeChatWithAppid", "(Ljava/lang/String;)V", wxappid);
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			jsb.reflection.callStaticMethod("AppController", "registerWeChat:", wxappid);
		}
	}

	wxShare(reqContent) {
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sendWxShareRequest", "(Ljava/lang/String;)V", JSON.stringify(reqContent));
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			var Type = reqContent.type + "";
			var Scene = reqContent.scene + "";
			var Title = reqContent.title + "";
			var Describe = reqContent.description + "";
			var Path = reqContent.content + "";
			jsb.reflection.callStaticMethod("AppController", "shareWeChatSecondWay:Scene:Title:Describe:Path:", Type, Scene, Title, Describe, Path);
		}
	}
	sendWxAuthRequest(reqState) {
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sendWxAuthRequest", "(Ljava/lang/String;)V", reqState);
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			jsb.reflection.callStaticMethod("AppController", "authurWithWeChat:", reqState);
		}
	}
	checkInstallWX() {
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			var install = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "checkInstall", "(Ljava/lang/String;)Z", "com.tencent.mm");
			return install
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			var install = jsb.reflection.callStaticMethod("AppController", "checkInstall:", "weixin://");
			return install
		}
	}
	sendfileOSS(filepath) {
		if (cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "SendFileToOSS",
				"(Ljava/lang/String;)Ljava/lang/String;", filepath);
		} else if (cc.sys.os == cc.sys.OS_IOS) {
			var endpoint = cc.vv.GLConfig.OSS_ENDPOINT;
			var bucketname = cc.vv.GLConfig.OSS_BUCKET_NAME;
			var accesskeyid = cc.vv.GLConfig.OSS_ACCESSKEYID;
			var accesskeysecret = cc.vv.GLConfig.OSS_ACCESSKEYSECRET;
			jsb.reflection.callStaticMethod("AppController", "SendFileToOSS:endpoint:bucketname:accesskey:accesskeysecret:", filepath, endpoint, bucketname, accesskeyid, accesskeysecret);
		}
	}
	//获取通讯录信息
	getContacters() {
		if (cc.sys.isNative) {
			var returnMap = [];
			if (cc.sys.os == cc.sys.OS_ANDROID) {
				//返回的是str  需要拆分
				var str = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "getContactersJs", "()Ljava/lang/String;");
				if (str == '[]') {
					return returnMap;
				}
				var arrystr = null;
				if (str && str.length > 0) {
					let temp = str.split("[");
					if (temp && temp[1]) {
						let temp2 = temp[1].split("]")
						if (temp2 && temp2[0]) {
							arrystr = temp2[0].split(',')
						}
					}
				}
				if (!arrystr || arrystr.length <= 0) {
					return returnMap
				}
				for (var s = 0; s < arrystr.length; s++) {
					if (arrystr[s] != "") {
						var t = arrystr[s].split("+")
						//通讯录字符串处理 通讯录可能会出现用户输入的一大堆乱码
						let name = "";
						if(t[0] && t[0].split("=")){
							name = t[0].split("=")[1];
						}
						let phone = "";
						if(t[1] && t[1].split("=")){
							phone = t[1].split("=")[1];
						}
						let note = "";
						if(t[2] && t[2].split("=")){
							note = t[2].split("=")[1];
						}
						returnMap[s] = { "name": name, "phone": phone, "note": note };
					}
				}
			}
			if (cc.sys.os == cc.sys.OS_IOS) {
				var str = jsb.reflection.callStaticMethod("AppController", "getContactersJs");
				console.log("ios 获取到的通讯录数据是", str)
				if (str) {
					let arrystr = JSON.parse(str)
					return arrystr;
				}
			}
			return returnMap;
		} else {
			//	cc.vv.GLUtils.showTips("只支持手机端获取通讯录信息");
		}
	}
	//跳转到通讯录
	jumpContacters() {
		if (cc.sys.isNative) {
			if (cc.sys.os == cc.sys.OS_ANDROID) {
				jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "jumpToContacters", "()V");
			} else if (cc.sys.os == cc.sys.OS_IOS) {
				jsb.reflection.callStaticMethod("AppController", "jumpToContacters");
			}
		} else {
			cc.vv.GLUtils.showTips("只支持手机端跳转通讯录");
		}
	}

	//跳转到短信
	jumpAndSendMessage(messageStr, phonenumber) {
		if (cc.sys.isNative) {
			if (cc.sys.os == cc.sys.OS_ANDROID) {
				jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sendSMS", "(Ljava/lang/String;Ljava/lang/String;)V", messageStr, phonenumber);
			} else if (cc.sys.os == cc.sys.OS_IOS) {
				jsb.reflection.callStaticMethod("AppController", "sendSMS:phonenumber:", messageStr, phonenumber);
			}
		} else {
			cc.vv.GLUtils.showTips("只支持手机端跳转短信");
		}
	}

	setPushAliasAndTags(alias,tag){
	}
	//获取极光推送的标签
	getPushTag(){
		return "dealer";
	}


	getRegistrationID(){
		var RegistrationID = "";
		return RegistrationID;
	}

	setCallBack(fun, name) {
		var funName = "";
		if (name) {
			console[name] = function (params) {
				fun(params);
			};
			funName = "console." + name;
		} else {
			console.nativeToJsCallback = function (params) {
				fun(params);
			};
			funName = "console.nativeToJsCallback";
		}
		return funName;
	}
	/////////////////////高防///////////////////////////

	//获取安全代理的IP和端口
	getServerIpAndPort(ip, port) {
		console.log("__ip = " + ip);
		console.log("——————port = " + port);

		var ret = {
			ip: ip,
			port: port
		};
		console.log("_____getURL = " + JSON.stringify(ret));
		return ret;
	}

	//获取游戏客户端真实ip
	getClientIp() {
		var ret = "127.0.0.0";
		// if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
		// 	ret = jsb.reflection.callStaticMethod(
		// 		this.Get_CLIPBOARD,
		// 		"getClientIp",
		// 		"()Ljava/lang/String;"
		// 	);
		// } else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
		// 	ret = jsb.reflection.callStaticMethod("AppController", "getClientIp");
		// }
		console.log("___getClientIp = " + ret);
		return ret;
	}

	//获取本地代理监听端口,dest_port为业务端口，成功返回本地端口,失败返回-1;
	getLocalPort(dest_port) {
		var proxy_port = 0;
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			proxy_port = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getLocalPort",
				"(Ljava/lang/String;I)I",
				dest_port
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			cc.log("-------------------111111111111111");
			proxy_port = jsb.reflection.callStaticMethod(
				"TaiChiAppVest",
				"getLocalPort:",
				dest_port
			);
		} else {
			proxy_port = dest_port || 0;
		}
		return proxy_port;
	}
	//获取本地代理ip;
	getProxyServerIP() {
		var proxy_ip = "";
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			proxy_ip = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getProxyServerIP",
				"()Ljava/lang/String;"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			cc.log("-------------------2222222222222");
			proxy_ip = jsb.reflection.callStaticMethod(
				"TaiChiAppVest",
				"getProxyServerIP"
			);
		} else {
			proxy_ip = "";
		}
		return proxy_ip;
	}
	//获取http业务的本地代理监听端口,host为URL中的域名,dest_port为业务端口成功返回本地端口，失败返回-1;
	//string host, int dest_port; return int;
	getHttpLocalPort(host, dest_port) {
		var http_local_port = 0;
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			http_local_port = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getHttpLocalPort",
				"(Ljava/lang/String;I)I",
				host,
				dest_port
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			http_local_port = jsb.reflection.callStaticMethod(
				"TaiChiAppVest",
				"getHttpLocalPort:dest_port",
				host,
				dest_port
			);
			cc.log("exit port---------------", http_local_port);
		} else {
			http_local_port = dest_port;
		}
		return http_local_port;
	}
	////////////////////////////////////////////////////
	//保存剪切板
	setClipboard(str) {
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			jsb.reflection.callStaticMethod(
				this.Set_CLIPBOARD,
				"CopyStrtoClipboard",
				this.ONE_STRING_PARAMS,
				str
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			jsb.reflection.callStaticMethod(
				"AppController",
				"CopyStrtoClipboard:",
				str
			);
		}
	}
	//读取剪切板
	getClipboard() {
		var ret = "";
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			ret = jsb.reflection.callStaticMethod(this.Get_CLIPBOARD, "pasteFromClipboard", "()Ljava/lang/String;");
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			ret = jsb.reflection.callStaticMethod("AppController", "readFromPasteBoard");
		}
		console.log("___getClipboard = " + ret);
		return ret;
	}

	//拉起微信
	skipToThirdApp(str) {
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			var funName = "cc.vv.GLSDKMgr.wechatSkipCallBack";
			jsb.reflection.callStaticMethod(
				this.Set_CLIPBOARD,
				"SkipToThirdApp",
				this.TWO_STRING_PARAMS,
				str,
				funName
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			//todo
			var funName = "cc.vv.GLSDKMgr.wechatSkipCallBack1";
			jsb.reflection.callStaticMethod("WXApiManager", "skipWX:", funName);
			// jsb.reflection.callStaticMethod("AppController", "SkipToThirdApp:", str);
		}
	}

	getVersionType() {
		var ret = 0;
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			ret = jsb.reflection.callStaticMethod(
				this.Get_CLIPBOARD,
				"getVersionType",
				"()I"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			ret = jsb.reflection.callStaticMethod("AppController", "getVersionType");
		}
		return ret;
	}

	// 获取设备ID
	getMobileId() {
		//return cc.vv.uuid.getcc.vv.uuid();

		var udId = "";
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			udId = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getDeviceId",
				"()Ljava/lang/String;"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			udId = jsb.reflection.callStaticMethod(
				"AppController",
				"getDeviceIDInKeychain"
			);
		} else {
			udId = cc.vv.uuid.getUuid(); //"dadbx82387192" + (new Date()).getTime();
		}
		console.log("_________________________udid = " + udId);
		// udId = cc.vv.GMd5(udId + "");
		return udId;
	}

	//cc.vv.GLSDKMgr.backFromThirdGame
	backFromThirdGame() {
		cc.vv.eventCustom.emit("AGGameBack");
	}
	/**
	 * 登录;
	 */
	login(auth_type) {
		cc.vv.GLNetDataModel.setAuthType(auth_type);
		switch (auth_type) {
			case cc.vv.GLDefine.EAuthType.GUEST:
			case cc.vv.GLDefine.EAuthType.ACCOUNT:
			case cc.vv.GLDefine.EAuthType.ACCOUNT_TOKEN:
				{
					cc.vv.GLNet._login();
				}
				break;
			case cc.vv.GLDefine.EAuthType.WECHAT:
				{
					this.wechatLogin();
				}
				break;
			default:
				console.error("-----sdk login auth type is error! type: " + auth_type);
				break;
		}
	}

	// 微信登录
	wechatLogin() {
		if (cc.sys.isNative) {
			cc.vv.wxChatMgr.getWxAuthToLogin();
		} else {
			// let wechat = 
			let getQueryVariable = (variable)=>
			{
				   var query = window.location.search.substring(1);
				   var vars = query.split("&");
				   for (var i=0;i<vars.length;i++) {
						   var pair = vars[i].split("=");
						   if(pair[0] == variable){return pair[1];}
				   }
				   return(false);
			}
			let wechattoken = getQueryVariable("token") || "fdgfgdfgdfgdff"
			let userinfo = {
				auth_type:"WECHAT",
				phone:"",
				vcode:"",
				wechat:wechattoken,//cqqqqqwee,jjssssss,16461641fadf2,123468946533333,123468946533334,ffffffff,1234689465333335
				ip:"127.0.0.1",
				location:"四川成都",
				device_type: "安卓",
				device_imei: "vivo",
				wechat_logo:"https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKg1Tf7R9hl7DFH2fafE8yCT7UZh3wTQXEgtb2uYEHKdmYE2uXpibg9aZSK36AFHS4g2Y2TsbrmbAw/132",
				wechat_name:`张三${ Math.floor(Math.random() * 10000 ) }`,
				wechat_sex:1,
			}
			this.wechatLoginCallback(userinfo);
		}
	}
	// 微信登录回调
	wechatLoginCallback(params) {
		console.log("wechatLoginCallback :" + JSON.stringify(params));

		var result = params;
		cc.vv.GLNetDataModel.platform_ret_data.authType = cc.vv.GLDefine.EAuthType.WECHAT;
		cc.vv.GLNetDataModel.platform_ret_data.userId = result.openId;
		cc.vv.GLNetDataModel.platform_ret_data.password = result.refreshToken;
		cc.vv.GLNetDataModel.platform_ret_data.refreshToken = result.refreshToken;
		cc.vv.GLNetDataModel.platform_ret_data.unionId = result.unionId;
		cc.vv.GLNetDataModel.platform_ret_data.name = result.rolename;
		cc.vv.GLNetDataModel.platform_ret_data.sex = result.sex == 0 ? cc.vv.GLDefine.ESexType.FEMALE : result.sex;
		cc.vv.GLNetDataModel.platform_ret_data.avatar = result.avatar;
		cc.vv.GLNetDataModel.platform_ret_data.is_update = true;
		var timestamp = Date.parse(new Date() + "");
		timestamp = timestamp / 1000;
		cc.vv.GLNetDataModel.platform_ret_data.updateDate = timestamp;

		cc.vv.GLNet.register(result);
	}

	XIAOLIAOLoginCallback(){
		cc.vv.GLNet.loginXIAOLIAO({});
	}

	// 失败后关闭界面
	loginFailedCallback() {
		cc.vv.UIMgr.close(cc.vv.GLConfig.waiting_path, cc.vv.UIMgr.closeType.hide);
		if (cc.vv.Login) {
			//cc.vv.Login.showLogin();
		}
	}
	//////////////////////////////////////////////////////////////////////
	/**
	 * 跳转链接;
	 */
	openURL(url) {
		cc.sys.openURL(url);
	}

	//////////////////////////周边/////////////////////////////

	// Mark:获取电量信息
	getElectricQuantity() {
		var quantity = "";
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			quantity =
				jsb.reflection.callStaticMethod(
					this.NATIVE_HELPER,
					"getBatteryStatus",
					"()I"
				) /
				100 +
				"";
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			quantity =
				jsb.reflection.callStaticMethod(
					"AppController",
					"getElectricQuantity"
				) /
				100 +
				"";

			cc.log("返回电量:", quantity);
		} else {
			quantity = "1";
		}

		return quantity;
	}
	//获取网络状态;
	getNetworkState() {
		var reachabilityStatus = -1;
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			reachabilityStatus = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getNetworkStates",
				"()I"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			reachabilityStatus = jsb.reflection.callStaticMethod(
				"AppController",
				"getNetworkStates"
			);
		}
		// console.log("________reachabilityStatus = " + reachabilityStatus);
		if (reachabilityStatus == 0) {
			reachabilityStatus = cc.vv.GLDefine.ENetworkState.WIFI;
		} else if (
			reachabilityStatus == 2 ||
			reachabilityStatus == 3 ||
			reachabilityStatus == 4
		) {
			reachabilityStatus = cc.vv.GLDefine.ENetworkState.PHONE;
		} else {
			reachabilityStatus = cc.vv.GLDefine.ENetworkState.UNKNOW;
		}

		// console.log("____reachabilityStatus = " + reachabilityStatus);
		return reachabilityStatus;
	}

	//获取相册路径
	getCameraPath() {
		var cameraPath = "";
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			cameraPath = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getCameraPath",
				"()Ljava/lang/String;"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
		}
		console.log("________cameraPath = " + cameraPath);
		return cameraPath;
	}
	//保存图片到相册
	saveImageToPhotos(fromPath) {
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			console.log("___-saveImageToPhotos = " + fromPath);
			jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"saveImageToPhotos",
				this.TWO_STRING_PARAMS,
				fromPath,
				"changcheng"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			// var data = jsb.fileUtils.getDataFromFile(fromPath);
			console.log("_______saveImageToPhotos = " + fromPath);

			jsb.reflection.callStaticMethod(
				"AppController",
				"saveImageToPhotos:",
				fromPath
			);
		}
	}

	//获取手机厂商
	getDeviceBrand() {
		var brand = "";
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			brand = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getDeviceBrand",
				"()Ljava/lang/String;"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			brand = "苹果";
		}
		brand = brand || "未知";
		console.log("______brand = " + brand);
		return brand;
	}

	//获取手机型号
	getSystemModel() {
		var model = "";
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			model = jsb.reflection.callStaticMethod(
				this.NATIVE_HELPER,
				"getSystemModel",
				"()Ljava/lang/String;"
			);
		} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
			model = jsb.reflection.callStaticMethod(
				"AppController",
				"getSystemModel"
			);
		}
		model = model || "未知";
		console.log("______model= " + model);
		return model;
	}

	//设置屏幕方向
	setOrientation(dir) {
	}

	startScanQrcode() {
		if (cc.sys.isNative) {
			if (cc.sys.os == cc.sys.OS_ANDROID) {
				jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "goScanJS", "()V");
			}
			else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
				jsb.reflection.callStaticMethod("AppController", "goScanJS");
			}
		} else {
			cc.vv.GLUtils.showTips("andirod或者ios机器上支持扫码")
		}
	}

	// 扫码结果回调
	scanQCodeResult(content) {
		cc.vv.eventCustom.emit("scanQCodeResult", content)
	}
	/**
	 * 新消息提醒
	 * @param alert 铃声/震动 类型 (例: "1.0/1.1": 铃声震动, "0.1": 震动, "0.0": 静音)
	 */
	NewMsgAlert(alert: string) {
		if (!alert) return false;//MsgAlert		
		if (cc.sys.isNative) {
			if (cc.sys.os == cc.sys.OS_ANDROID) {
				//jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "MsgAlert", "(Ljava/lang/String;)V", alert);
			}
			else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
				//待实现
			}
		} else {
			cc.vv.GLUtils.showTips("andirod或者ios机器上支持铃声震动提醒");
		}
		return true;
	}
	OnClickBackBtn() {
		// console.log('点击了系统返回键!!!!!!!!');
		// return;
		// cc.vv.syskeyMgr.onClickSysKey_Back();
	}

	closekeyboardJs() {
		if (cc.sys.isNative) {
			if (cc.sys.os == cc.sys.OS_ANDROID) {
				jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "closekeyboardJs", "()V");
			} else if (cc.sys.os == cc.sys.OS_IOS) {
				jsb.reflection.callStaticMethod("AppController", "closekeyboardJs")
			}
		}
	}
	openkeyboardJs() {
		if (cc.sys.isNative) {
			if (cc.sys.os == cc.sys.OS_ANDROID) {
				jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "openkeyboardJs", "()V");
			} else if (cc.sys.os == cc.sys.OS_IOS) {
				jsb.reflection.callStaticMethod("AppController", "openkeyboardJs")
			}
		}
	}

	/***
	 * @isCut 相机照片是否需要剪切
	 * 打开相机
	 */
	public openPhoneCamera(isCut: boolean = false): void {
	}
	/**
	 * @isCut 相册图片是否需要剪切
	 * 打开相册
	 */
	public openPhonePhotoAlbum(isCut: boolean = false): void {
	}

}

export let glSDKMgr: GLSDKMgr = new GLSDKMgr(); //
